package com.wx.pay.util;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
 * @Description: Stream工具类
 * @author kinfeng
 * @date 2015年12月10日 下午1:35:46 
 * @version V1.0
 */
public class StreamUtil {
	/**
	 * 读取流中的字符串
	 * @param in
	 * @return
	 * @throws IOException
	 */
	public static String readString(InputStream in) throws IOException{
		if(in==null){
			return null;
		}
		StringBuffer result = new StringBuffer();
		InputStreamReader isr = null;
		BufferedReader br = null;
		String row = null;
		try {
			isr = new InputStreamReader(in, "UTF-8");
			br = new BufferedReader(isr);
			while((row=br.readLine())!=null){
				result.append(row);
			}
		} catch (IOException e) {
			throw e;
		}finally{
			if(isr!=null){
				isr.close();
			}
			if(br!=null){
				br.close();
			}
		}
		return result.toString();
	}
}

